`ifndef TRANSACTION_SVH
`define TRANSACTION_SVH

class trans_base;
	protected bit [3:0] a;
	local bit [3:0] b;

	virtual function void setb(input bit [3:0] b);
		this.b = b;
	endfunction

	virtual function void print(string name = "");
		$display("%s: a=%0h, b=%0h", name, a, b);
	endfunction
endclass

class trans_a extends trans_base;
	function new(input bit [3:0] a = 0);
		this.a = a; // 派生类可以访问protected成员
		// this.b = 4'h2; // 派生类不能访问local成员
	endfunction

	virtual function void print(string name = "");
		super.print(name);
		// $display("%s: a=%0h, b=%0h", name, a, b);
	endfunction
endclass

`endif
